package com.along.utility.common.response;

/**
 *
 * @author jingjiwu
 * @date 2021-01-11 17:15:37
 * @param <T>
 */
public class Result<T> {
	private T data;
	private Integer code;
	private String msg;
	private String signType;
	private String sign;

	public static <T> Result<T> success(T data, String sign) {
		return new Result<T>(DefaultResultCode.SUCCESS, data, sign);
	}

	public static <T> Result<T> error(ResultCode resultCode) {
		return new Result<T>(resultCode, null, "");
	}

	public static <T> Result<T> of(ResultCode resultCode, T data) {
		return new Result<T>(resultCode, data);
	}

	public static <T> Result<T> of(ResultCode resultCode) {
		return new Result<T>(resultCode, null);
	}

	public static <T> Result<T> of(ResultCode resultCode, T data, String sign) {
		return new Result<T>(resultCode, data, sign);
	}

	private Result(ResultCode resultCode, T data) {
		this.code = resultCode.getValue();
		this.msg = resultCode.getMessage();
		this.data = data;
	}

	private Result(ResultCode resultCode, T data, String sign) {
		this.code = resultCode.getValue();
		this.msg = resultCode.getMessage();
		this.data = data;
		this.signType = "RSA";
		this.sign = sign;
	}

	public Result() {
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getSignType() {
		return signType;
	}

	public void setSignType(String signType) {
		this.signType = signType;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

}
